﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using DataService;

public partial class Server_Firewall_default :BasePage
{
     private DeviceService _service;
     private IList<Firewall> _firewalls;
     private IList<Device> _devices;
    public Server_Firewall_default()
    {
        _service = new DeviceService();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (UserLogin == null)
        {
            Response.Redirect("~/Login.aspx");
        }
        if (string.IsNullOrEmpty(Request.QueryString["Firewallid"]))
        {
            Response.Redirect("default.aspx");
        }
        if (!IsPostBack)
        {
            LoadGrid();
        }
    }

    private void LoadGrid()
    {
        _firewalls = _service.GetFirewallByFirewallId(Convert.ToInt32(Request.QueryString["FirewallId"]));
        if (_firewalls.Count > 0)
        {
            dlFirewall.DataSource = _firewalls;
            dlFirewall.DataBind();
            lblIPFirewall.Text = _firewalls[0].IP;
        }
        _devices = _service.GetListDeviceByAccountIdAndFirewallId(UserLogin.Customer.Id, Convert.ToInt32(Request.QueryString["FirewallId"]));
        if (_devices.Count > 0)
        {
            dlDevices.DataSource = _devices;
            dlDevices.DataBind();
        }
    }
}